\hypertarget{classSymbolTable}{
\section{SymbolTable Class Reference}
\label{classSymbolTable}\index{SymbolTable@{SymbolTable}}
}


symboltable object that stores lexemes, IDentifiers and Locations as keys.  




{\ttfamily \#include $<$symboltable.h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classSymbolTable_a1fbe6cec5594463b766db0ac58c9aa1d}{SymbolTable} ()
\begin{DoxyCompactList}\small\item\em Basic constructor. \item\end{DoxyCompactList}\item 
\hyperlink{classSymbolTable_a5d5ae9b5b22d87691cec9ec17cfff650}{$\sim$SymbolTable} ()
\item 
int \hyperlink{classSymbolTable_a1df7dfc3592c924e8c8a9fea1e13bf89}{makeEntry} (string)
\begin{DoxyCompactList}\small\item\em Adds another entry to table and increases the index then returning the previous index value. \item\end{DoxyCompactList}\item 
int \hyperlink{classSymbolTable_a064e30f7ddbd4065244d1d41ea885737}{makeEntry} (string, string, string)
\begin{DoxyCompactList}\small\item\em A new table entry is made with a predetermined name, lexeme/attribute and value of said attribute. \item\end{DoxyCompactList}\item 
void \hyperlink{classSymbolTable_ac7a86e820025627863b4277cf84353a0}{addAttribute} (int, string, string, string)
\begin{DoxyCompactList}\small\item\em Assigns a new value to the lexeme at the specified location. \item\end{DoxyCompactList}\item 
map$<$ int, map$<$ string, map$<$ string, string $>$ $>$ $>$ \hyperlink{classSymbolTable_ad9429553f1aadeade3339e32e4f4c61e}{get} ()
\begin{DoxyCompactList}\small\item\em Returns a copy of the current symbol table. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSymbolTable_af93b3c97308b5cfe7661e57b83d8dc35}{attributeExists} (int, string, string)
\begin{DoxyCompactList}\small\item\em Checks if a given entry/lexeme actually exists or not. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSymbolTable_a7df0fef90bee097810b553ad2e1c6cec}{attributeValueExists} (int, string, string, string)
\begin{DoxyCompactList}\small\item\em Verify that the attribute value at the given entry matches the one the caller is examining. \item\end{DoxyCompactList}\item 
string \hyperlink{classSymbolTable_a0b0bdb5b1a6095782c6c4f318737a0a9}{findAttributeWhere} (string, string)
\begin{DoxyCompactList}\small\item\em Searches the table for an entry with a matching lexeme and token name. \item\end{DoxyCompactList}\item 
string \hyperlink{classSymbolTable_aa5e55d23f3b69e48a8e6c385bd9d509f}{getAttributeWhere} (int, string, string)
\begin{DoxyCompactList}\small\item\em Returns the value at the given Attribute location if it exists. \item\end{DoxyCompactList}\item 
int \hyperlink{classSymbolTable_a61a3da421ef79fffe47e8e2d3065bb05}{findIndexWhere} (string, string)
\begin{DoxyCompactList}\small\item\em We find the Index of a token entry using its name and attribute. \item\end{DoxyCompactList}\item 
int \hyperlink{classSymbolTable_a33fa9fe363246a0b54e9f58191ad931e}{findLexeme} (string)
\begin{DoxyCompactList}\small\item\em Returns an integer representing the location of a lexeme, so long as it is an ID and actual lexeme. \item\end{DoxyCompactList}\item 
int \hyperlink{classSymbolTable_a218f832e3d8b4d37cb3aee7af732a0c6}{getNumOfReservedWords} ()
\begin{DoxyCompactList}\small\item\em Returns the reserved word count. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSymbolTable_a70c8b5e2a159350ffefffffbf6d974ee}{indexExists} (int)
\begin{DoxyCompactList}\small\item\em Checks if a given index is within or at the end of the symbol table. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{classSymbolTable_ac98627cea258b0931be5286aacb1f478}{numberOfReservedWords}
\begin{DoxyCompactList}\small\item\em We store and return the number of possible reserved words. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
map$<$ int, map$<$ string, map$<$ string, string $>$ $>$ $>$ \hyperlink{classSymbolTable_a96f585bb42df3aad2e833e95681f0727}{table}
\begin{DoxyCompactList}\small\item\em Our symbol table is a Map with a Map with a Map, called \char`\"{}table\char`\"{}. \item\end{DoxyCompactList}\item 
int \hyperlink{classSymbolTable_a6e85689256b178941b87f51e570a6c1e}{index}
\begin{DoxyCompactList}\small\item\em An integer to index our symbol table easier. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
symboltable object that stores lexemes, IDentifiers and Locations as keys. The symbol table stores its values in a Map of a Map of a Map. The values themselves are the specific keys of each kind.

It provides multiple ways to access and change inner Symbol Table data, and stores said data in a fast access form.

The structure is thus able to scale vertically and horizontally by introducing more linked maps, or storing more key values and attributes.

For reference, String Compare returns a 0 if the comparison result is fully \char`\"{}true\char`\"{}. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classSymbolTable_a1fbe6cec5594463b766db0ac58c9aa1d}{
\index{SymbolTable@{SymbolTable}!SymbolTable@{SymbolTable}}
\index{SymbolTable@{SymbolTable}!SymbolTable@{SymbolTable}}
\subsubsection[{SymbolTable}]{\setlength{\rightskip}{0pt plus 5cm}SymbolTable::SymbolTable ()}}
\label{classSymbolTable_a1fbe6cec5594463b766db0ac58c9aa1d}


Basic constructor. 

Default constructor for symboltable, initializes index to 0 and sets reserved words.

We create a bunch of entries in our symbol table to reflect Reserved Words of the PL Language. The language specifies 17 particular reserved words, which we also store as an integer count. We set our index before making these entries. 

References index, makeEntry(), and numberOfReservedWords.

\hypertarget{classSymbolTable_a5d5ae9b5b22d87691cec9ec17cfff650}{
\index{SymbolTable@{SymbolTable}!$\sim$SymbolTable@{$\sim$SymbolTable}}
\index{$\sim$SymbolTable@{$\sim$SymbolTable}!SymbolTable@{SymbolTable}}
\subsubsection[{$\sim$SymbolTable}]{\setlength{\rightskip}{0pt plus 5cm}SymbolTable::$\sim$SymbolTable ()\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classSymbolTable_a5d5ae9b5b22d87691cec9ec17cfff650}


\subsection{Member Function Documentation}
\hypertarget{classSymbolTable_ac7a86e820025627863b4277cf84353a0}{
\index{SymbolTable@{SymbolTable}!addAttribute@{addAttribute}}
\index{addAttribute@{addAttribute}!SymbolTable@{SymbolTable}}
\subsubsection[{addAttribute}]{\setlength{\rightskip}{0pt plus 5cm}void SymbolTable::addAttribute (int {\em index}, \/  string {\em name}, \/  string {\em attribute}, \/  string {\em value})}}
\label{classSymbolTable_ac7a86e820025627863b4277cf84353a0}


Assigns a new value to the lexeme at the specified location. 

Adds/Alters an attribute at a specific index, specifying token name, attribute and value.


\begin{DoxyParams}{Parameters}
\item[{\em index}]\item[{\em name}]\item[{\em attribute}]\item[{\em value}]\end{DoxyParams}


References table.

\hypertarget{classSymbolTable_af93b3c97308b5cfe7661e57b83d8dc35}{
\index{SymbolTable@{SymbolTable}!attributeExists@{attributeExists}}
\index{attributeExists@{attributeExists}!SymbolTable@{SymbolTable}}
\subsubsection[{attributeExists}]{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::attributeExists (int {\em index}, \/  string {\em name}, \/  string {\em attribute})}}
\label{classSymbolTable_af93b3c97308b5cfe7661e57b83d8dc35}


Checks if a given entry/lexeme actually exists or not. 

Checks if a given attribute location exists based on an index and name.

This is separate from the lexeme's value.

It is important to note that this is not checking to see if that attribute has an actual value assigned to it, but merely that an entry that can house a value exists. 
\begin{DoxyParams}{Parameters}
\item[{\em index}]\item[{\em name}]\item[{\em attribute}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}


References table.

\hypertarget{classSymbolTable_a7df0fef90bee097810b553ad2e1c6cec}{
\index{SymbolTable@{SymbolTable}!attributeValueExists@{attributeValueExists}}
\index{attributeValueExists@{attributeValueExists}!SymbolTable@{SymbolTable}}
\subsubsection[{attributeValueExists}]{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::attributeValueExists (int {\em index}, \/  string {\em name}, \/  string {\em attribute}, \/  string {\em value})}}
\label{classSymbolTable_a7df0fef90bee097810b553ad2e1c6cec}


Verify that the attribute value at the given entry matches the one the caller is examining. 

Find if an attribute value exists given the information provided.

We check if the given lexeme exists, then check if the Value of it is equivalent to the one sent by the caller (the final String \char`\"{}value\char`\"{}). Could be used for Macro shorthands, will likely be used by the \hyperlink{classParser}{Parser}.


\begin{DoxyParams}{Parameters}
\item[{\em index}]\item[{\em name}]\item[{\em attribute}]\item[{\em value}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}


References attributeExists(), and table.

\hypertarget{classSymbolTable_a0b0bdb5b1a6095782c6c4f318737a0a9}{
\index{SymbolTable@{SymbolTable}!findAttributeWhere@{findAttributeWhere}}
\index{findAttributeWhere@{findAttributeWhere}!SymbolTable@{SymbolTable}}
\subsubsection[{findAttributeWhere}]{\setlength{\rightskip}{0pt plus 5cm}string SymbolTable::findAttributeWhere (string {\em tokenName}, \/  string {\em attribute})}}
\label{classSymbolTable_a0b0bdb5b1a6095782c6c4f318737a0a9}


Searches the table for an entry with a matching lexeme and token name. 

Return an attribute value given the tokenName and attribute.

Returns nothing if the attribute is not found. Otherwise it returns the attribute string at that specific lexemetic location.

Not sure how useful this will be later. IF there are multiple tokens with the same attribute names then this will return the first find. Which makes me believe this wont be very useful. 
\begin{DoxyParams}{Parameters}
\item[{\em tokenName}]\item[{\em attribute}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
attribute value on success, empty string on fail. 
\end{DoxyReturn}


References attributeExists(), index, and table.

\hypertarget{classSymbolTable_a61a3da421ef79fffe47e8e2d3065bb05}{
\index{SymbolTable@{SymbolTable}!findIndexWhere@{findIndexWhere}}
\index{findIndexWhere@{findIndexWhere}!SymbolTable@{SymbolTable}}
\subsubsection[{findIndexWhere}]{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::findIndexWhere (string {\em tokenName}, \/  string {\em attribute})}}
\label{classSymbolTable_a61a3da421ef79fffe47e8e2d3065bb05}


We find the Index of a token entry using its name and attribute. 

Find an index using a token name and attribute name.

Not sure how useful this will be 
\begin{DoxyParams}{Parameters}
\item[{\em tokenName}]\item[{\em attribute}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
index of found attribute, -\/1 on fail 
\end{DoxyReturn}


References attributeExists(), and index.

\hypertarget{classSymbolTable_a33fa9fe363246a0b54e9f58191ad931e}{
\index{SymbolTable@{SymbolTable}!findLexeme@{findLexeme}}
\index{findLexeme@{findLexeme}!SymbolTable@{SymbolTable}}
\subsubsection[{findLexeme}]{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::findLexeme (string {\em lexeme})}}
\label{classSymbolTable_a33fa9fe363246a0b54e9f58191ad931e}


Returns an integer representing the location of a lexeme, so long as it is an ID and actual lexeme. 

Finds a table entry with the given lexeme.

Otherwise, it returns -\/1.

This assumes the entry is an ID and attribute is a lexeme. It will return the index of the found entry, or a -\/1 if an entry is not found. \begin{DoxyReturn}{Returns}
int Integer representing the index of the found lexeme. 
\end{DoxyReturn}


References index, and table.

\hypertarget{classSymbolTable_ad9429553f1aadeade3339e32e4f4c61e}{
\index{SymbolTable@{SymbolTable}!get@{get}}
\index{get@{get}!SymbolTable@{SymbolTable}}
\subsubsection[{get}]{\setlength{\rightskip}{0pt plus 5cm}map$<$ int, map$<$ string, map$<$ string, string $>$ $>$ $>$ SymbolTable::get ()}}
\label{classSymbolTable_ad9429553f1aadeade3339e32e4f4c61e}


Returns a copy of the current symbol table. 

This function returns a copy of the Table.

\begin{DoxyReturn}{Returns}
std::map$<$int, std::map$<$std::string, std::map$<$std::string, std::string$>$ $>$ $>$ Symbol Table. 
\end{DoxyReturn}


References table.

\hypertarget{classSymbolTable_aa5e55d23f3b69e48a8e6c385bd9d509f}{
\index{SymbolTable@{SymbolTable}!getAttributeWhere@{getAttributeWhere}}
\index{getAttributeWhere@{getAttributeWhere}!SymbolTable@{SymbolTable}}
\subsubsection[{getAttributeWhere}]{\setlength{\rightskip}{0pt plus 5cm}string SymbolTable::getAttributeWhere (int {\em index}, \/  string {\em tokenName}, \/  string {\em attribute})}}
\label{classSymbolTable_aa5e55d23f3b69e48a8e6c385bd9d509f}


Returns the value at the given Attribute location if it exists. 

Returns a value at a given location if it exists.

Otherwise, we return the empty string. 
\begin{DoxyParams}{Parameters}
\item[{\em index}]\item[{\em tokenName}]\item[{\em attribute}]\end{DoxyParams}


References attributeExists(), and table.

\hypertarget{classSymbolTable_a218f832e3d8b4d37cb3aee7af732a0c6}{
\index{SymbolTable@{SymbolTable}!getNumOfReservedWords@{getNumOfReservedWords}}
\index{getNumOfReservedWords@{getNumOfReservedWords}!SymbolTable@{SymbolTable}}
\subsubsection[{getNumOfReservedWords}]{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::getNumOfReservedWords ()}}
\label{classSymbolTable_a218f832e3d8b4d37cb3aee7af732a0c6}


Returns the reserved word count. 



References numberOfReservedWords.

\hypertarget{classSymbolTable_a70c8b5e2a159350ffefffffbf6d974ee}{
\index{SymbolTable@{SymbolTable}!indexExists@{indexExists}}
\index{indexExists@{indexExists}!SymbolTable@{SymbolTable}}
\subsubsection[{indexExists}]{\setlength{\rightskip}{0pt plus 5cm}bool SymbolTable::indexExists (int {\em index})}}
\label{classSymbolTable_a70c8b5e2a159350ffefffffbf6d974ee}


Checks if a given index is within or at the end of the symbol table. 

Checks if the index we desire is at the end of our \hyperlink{classSymbolTable}{SymbolTable}.

If empty, then our search value is the end of the Symbol Table, thus we have no entry with that index. Otherwise, an entry was found that has said index. \begin{DoxyReturn}{Returns}
bool Boolean shows whether the index exists. 
\end{DoxyReturn}


References table.

\hypertarget{classSymbolTable_a064e30f7ddbd4065244d1d41ea885737}{
\index{SymbolTable@{SymbolTable}!makeEntry@{makeEntry}}
\index{makeEntry@{makeEntry}!SymbolTable@{SymbolTable}}
\subsubsection[{makeEntry}]{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::makeEntry (string {\em name}, \/  string {\em attribute}, \/  string {\em value})}}
\label{classSymbolTable_a064e30f7ddbd4065244d1d41ea885737}


A new table entry is made with a predetermined name, lexeme/attribute and value of said attribute. 


\begin{DoxyParams}{Parameters}
\item[{\em name}]\item[{\em attribute}]\item[{\em value}]\end{DoxyParams}


References index, and table.

\hypertarget{classSymbolTable_a1df7dfc3592c924e8c8a9fea1e13bf89}{
\index{SymbolTable@{SymbolTable}!makeEntry@{makeEntry}}
\index{makeEntry@{makeEntry}!SymbolTable@{SymbolTable}}
\subsubsection[{makeEntry}]{\setlength{\rightskip}{0pt plus 5cm}int SymbolTable::makeEntry (string {\em name})}}
\label{classSymbolTable_a1df7dfc3592c924e8c8a9fea1e13bf89}


Adds another entry to table and increases the index then returning the previous index value. 

An entry to the table is made with no information other than an input Name variable.

The index variable is used for the index location of the new entry, and the rest of the entry is empty. Our index is increased and the former index is returned. 
\begin{DoxyParams}{Parameters}
\item[{\em name}]\end{DoxyParams}


References index, and table.



\subsection{Member Data Documentation}
\hypertarget{classSymbolTable_a6e85689256b178941b87f51e570a6c1e}{
\index{SymbolTable@{SymbolTable}!index@{index}}
\index{index@{index}!SymbolTable@{SymbolTable}}
\subsubsection[{index}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf SymbolTable::index}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{classSymbolTable_a6e85689256b178941b87f51e570a6c1e}


An integer to index our symbol table easier. 

We use an automatically incrementing index for each entry we make, so we'll just store an auto-\/assigned integer within this symbol table. \hypertarget{classSymbolTable_ac98627cea258b0931be5286aacb1f478}{
\index{SymbolTable@{SymbolTable}!numberOfReservedWords@{numberOfReservedWords}}
\index{numberOfReservedWords@{numberOfReservedWords}!SymbolTable@{SymbolTable}}
\subsubsection[{numberOfReservedWords}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf SymbolTable::numberOfReservedWords}}}
\label{classSymbolTable_ac98627cea258b0931be5286aacb1f478}


We store and return the number of possible reserved words. 

This is static and specified by the language. \hypertarget{classSymbolTable_a96f585bb42df3aad2e833e95681f0727}{
\index{SymbolTable@{SymbolTable}!table@{table}}
\index{table@{table}!SymbolTable@{SymbolTable}}
\subsubsection[{table}]{\setlength{\rightskip}{0pt plus 5cm}map$<$ int, map$<$ string, map$<$ string, string $>$ $>$ $>$ {\bf SymbolTable::table}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{classSymbolTable_a96f585bb42df3aad2e833e95681f0727}


Our symbol table is a Map with a Map with a Map, called \char`\"{}table\char`\"{}. 

We define the symbol table using a map, the key being an integer index. The second value is another map, its key being the name of the token and the value being yet another map with its key being any attribute such as \char`\"{}lexeme\char`\"{} or \char`\"{}type\char`\"{} and that map's value is the value for that attribute.

So essentially we can get an item's lexeme by using the following: table\mbox{[}34\mbox{]}\mbox{[}\char`\"{}ID\char`\"{}\mbox{]}\mbox{[}\char`\"{}lexeme\char`\"{}\mbox{]}

This will allow us to store any number of attributes that we need to store in the symbol table. So it would be possible to add multiple lexemes for a given word. Essentially, this is akin to storing a linked list of attribute sets in a hashmap using linear probing.

This could also be accomplished with a Vector, but Vectors scale at a worse rate than a Map. 

The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
\hyperlink{symboltable_8h}{symboltable.h}\item 
\hyperlink{symboltable_8cpp}{symboltable.cpp}\end{DoxyCompactItemize}
